package controller;

import java.io.FileInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Properties;
import java.util.ResourceBundle;

public class Connection {
	
	HttpURLConnection connect = null;
	String url = null;
	URL urlservlet = null;
	protected static Properties config;
	protected FileInputStream inConfig;
	
	public HttpURLConnection getConnection()
	{
		if(connect == null){
			try {
				inConfig = new FileInputStream("appClientModule/config.properties");
				config = new Properties();
				config.load(inConfig);
				inConfig.close();
				
				urlservlet = new URL(config.getProperty("url"));
				connect=(HttpURLConnection)urlservlet.openConnection();
				connect.setDoInput(true);
				connect.setDoOutput(true);	
				connect.setRequestMethod("POST");
			} 

			catch (MalformedURLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}	
		}

		return connect;
	}

}
